$(document).ready(function() {
    $(".pg_btn").on("tap",function(){
        // $(".pg_btn").attr("disabled",true);
        let work = $("#work").val();
        let money = $("#money").val();
        let wages = parseFloat($("#wages").val());
        let fire = $('input:radio[name="fire"]:checked').val();
        let labor = $('input:radio[name="labor"]:checked').val();
        let social = $('input:radio[name="social"]:checked').val();
        let tel = $("#phoner").val();
        let url = document.URL;
     
        if (work != "" && money != "" && (/^1[3456789]\d{9}$/.test(tel)) && (/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(wages))) {
            $.post("http://yh.cn/api/index/calculator_post",{working_hours:work,tardy_hours:money,wages:wages,is_fire:fire,is_sign:labor,social_security:social,phone:tel,url:url},function(data){
                if (data == 1) {
                    mui.alert('恭喜您，预约成功！','提示',function () {
                        window.location.reload();
                    })
                }else{
                    mui.alert('系统错误,请联系管理员或刷新页面!','提示',function () {
                        window.location.reload();
                    })
                }
			},"json")
        } else {
            $(".pg_btn").attr("disabled",false);
            mui.alert('请检查输入信息！', '提示',function(){
				if (!(/^1[3456789]\d{9}$/.test(tel))) {
					$("#phoner").css("border","1px solid red");

				}
                if (wages == "") {
                    $("#wages").css("border","1px solid red");

                }
				if (money == "") {
					$("#money").css("border","1px solid red");

                }
                if (work == "") {
					$("#work").css("border","1px solid red");

				}
			});
        } 
    });
    $("#phoner").keydown(() => {
        bor($("#phoner"));
    })
    $("#wages").keydown(() => {
        bor($("#wages"));
    })
    $("#money").keydown(() => {
        bor($("#money"));
    })
    $("#work").keydown(() => {
        bor($("#work"));
    })
})
function bor(tab){
    tab.css("border","none");
}